<!--权限编辑-->
<template>
  <div>
    <el-dialog
      title="权限编辑"
      :visible.sync="editActionVisible"
      width="40%"
      :show-close="false"
      :close-on-click-modal="false">

      <el-form ref="editActionFormData" :model="editActionFormData" :rules="editActionFormData_rules" label-width="100px">
        <el-form-item label="权限名称" prop="action_name">
          <el-input v-model="editActionFormData.action_name" size="small"></el-input>
        </el-form-item>
        <el-form-item label="权限图标" prop="action_action">
          <el-input v-model="editActionFormData.action_action" size="small"></el-input>
        </el-form-item>

        <el-form-item label="权限路径" prop="url">
          <el-input v-model="editActionFormData.url" size="small"></el-input>
        </el-form-item>

      </el-form>

      <span slot="footer" class="dialog-footer">
    <el-button size="mini" @click="closeEditAction">取 消</el-button>
    <el-button size="mini" type="primary" @click="updateAction">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {updateAction} from '@/api/permission'
  export default{
      props:["isShowEditAction","actionData"],
      data(){
          return {
            editActionVisible:this.isShowEditAction,
            editActionFormData:{
                action_name:null,
                action_action:null,
                url:null
            },

            //编辑信息校验
            editActionFormData_rules:{
              action_name:[
                { required: true, message: '权限名不能为空', trigger: 'change' },
              ],
              url:[
                { required: true, message: '权限路径不能为空', trigger: 'change' },
              ]
            }
          }
      },

      mounted(){
          this.editActionFormData = this.actionData;
      },

      methods:{
        //关闭弹出框
        closeEditAction(){
            this.editActionVisible = false;
            this.$emit("closeDialog","edit");
        },

        //修改数据
        updateAction(){
          updateAction(this.editActionFormData).then(res=>{
              if(res.code == 200){
                this.$message({
                  message: '信息修改成功',
                  type: 'success'
                });
                this.closeEditAction();
              }
          });
        }
      }
  }
</script>
